package com.tarena.action;

import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.tarena.bo.DeptDao;
import com.tarena.bo.UserDao;
import com.tarena.controller.Action;
import com.tarena.vo.Dept;
import com.tarena.vo.User;

/**
 * @添加员工表单处理类
 * @author WangPeihu
 * @since 31/12/2009
 * @Team [Never give up]
 */
public class AddEmpFormAction extends Action {
	private DeptDao dd = new DeptDao();
	private UserDao ud = new UserDao();

	@Override
	public void execute(HttpServletRequest request, HttpServletResponse response) {
		try {
			List<Dept> deptList = dd.findAllDept();
			request.setAttribute("deptList", deptList);
			HttpSession session = request.getSession();
			User user1 = (User) session.getAttribute("user_key");
			User user2 = ud.getUser(user1);
			request.setAttribute("user_detail", user2);
			RequestDispatcher rd = request
					.getRequestDispatcher("/WEB-INF/jsp/emp_add_form.jsp");
			rd.forward(request, response);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}

}
